<template>
  <div class="content">
    <!--    生产订单弹窗-->
    <el-dialog
      v-dialogDrag
      title="生产订单列表"
      model
      :visible.sync="isclientlDialog"
      :close-on-click-modal="false"
      width="60%"
      :before-close="handleClose"
    >
      <div class="materiel-form">
        <span class="materiel-code">{{ $t('shop.name1') }}</span>
        <el-input v-model.trim="client.fname" class="input-width" size="mini" placeholder="请输入名称" @keyup.enter.native="clientSearch" />
        <el-button size="mini" type="primary" @click="clientSearch">{{ $t('btn.search') }}</el-button>
      </div>
      <jc-table
        :table-data="clientlDialogData"
        :table-header="clientDialogHeader"
        table-height="53vh"
        serial
        @clickRow="clientlSelectRow"
      />
      <jc-pagination
        v-show="client.total > 0"
        :total="client.total"
        :page.sync="client.pageNum"
        :limit.sync="client.pageSize"
        @pagination="queryTBdCustomerList"
      />
    </el-dialog>
  </div>
</template>
<script>
import { queryMoNoList } from '@/api/quality/index'
import { toMxAmina } from '@/components/ToMxamineState'

export default {
  props: {
    msg: {
      type: [String, Number],
      default: ''
    }
  },
  data() {
    return {
      // 品质生产订单列表数据分页
      isclientlDialog: true,
      client: {
        total: 0, // 总条目
        pageNum: 1, // 当前页
        pageSize: 200, // 每页显示多少条数据
        fname: ''
        // fuseOrgId: this.msg || ''
      },
      clientlDialogData: [],
      clientDialogHeader: [
        { label: this.$t('menu.collect'), prop: 'fbillNo' },
        { label: this.$t('market.fdate'), prop: 'fdate' },
        { label: this.$t('market.deaprt'), prop: 'fworkshop' },
        { label: this.$t('market.paezText1'), prop: 'salkhddh' },
        { label: this.$t('shop.state'), prop: 'fdocumentStatus' }
      ],
      prodValue: { fcustId: '', fname: '', isclientlDialog: true }
    }
  },
  created() {
    this.queryTBdCustomerList()
  },
  methods: {
    // 获取品质生产订单列表
    async queryTBdCustomerList() {
      const DATA = {
        ...this.client
      }
      const { data: RES } = await queryMoNoList(DATA)
      this.clientlDialogData = RES.array.map(item => {
        return toMxAmina(item)
      })
      this.client.total = RES.total
    },
    // 品质生产订单弹窗选中
    clientlSelectRow(item) {
      this.prodValue = item
      this.$emit('product', this.prodValue)
    },
    clientSearch() {
      this.client.pageNum = 1
      this.queryTBdCustomerList()
    },
    // 关闭前回调
    handleClose() {
      this.prodValue.isclientlDialog = false
      this.$emit('product', this.prodValue)
    }
  }
}
</script>

<style scoped lang="scss">
.content {
  @include listBom;
}
</style>
